package com.ruoyi.web.controller.vqms;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.vqms.domain.VQMSQueueArea;
import com.ruoyi.vqms.service.IVQMSQueueAreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 排队队列 控制器
 */
@RestController
@RequestMapping("/vqms/queue/area")
public class VQMSQueueAreaController extends BaseController {
    @Autowired
    private IVQMSQueueAreaService queueAreaService;

    /**
     * 查询排队队列列表(不分页)
     */
    @PreAuthorize("@ss.hasPermi('vqms:queue:area:list')")
    @RequestMapping("/getList")
    public AjaxResult getList(VQMSQueueArea vqmsQueueArea){
        return AjaxResult.success(queueAreaService.selectList(vqmsQueueArea));
    }

    /**
     * 查询排队队列列表
     */
    @PreAuthorize("@ss.hasPermi('vqms:storehouseLocation:list')")
    @RequestMapping("/list")
    public TableDataInfo list(VQMSQueueArea vqmsQueueArea){
        startPage();
        List<VQMSQueueArea> list=queueAreaService.selectList(vqmsQueueArea);
        return getDataTable(list);
    }

    /**
     * 新增排队队列
     */
    @Log(title = "新增排队队列", businessType = BusinessType.INSERT)
    @PreAuthorize("@ss.hasPermi('vqms:queue:area:add')")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody VQMSQueueArea vqmsQueueArea){
        vqmsQueueArea.setCreateBy(SecurityUtils.getUsername());
        queueAreaService.add(vqmsQueueArea);
        return AjaxResult.success();
    }

    /**
     * 查询排队队列
     */
    @PreAuthorize("@ss.hasPermi('vqms:queue:area:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable Long id) {
        return AjaxResult.success(queueAreaService.getById(id));
    }

    /**
     * 修改排队队列
     */
    @Log(title = "修改排队队列", businessType = BusinessType.UPDATE)
    @PreAuthorize("@ss.hasPermi('vqms:queue:area:update')")
    @PutMapping(value = "/update")
    public AjaxResult update(@RequestBody VQMSQueueArea vqmsQueueArea)
    {
        vqmsQueueArea.setUpdateBy(SecurityUtils.getUsername());
        queueAreaService.update(vqmsQueueArea);
        return AjaxResult.success();
    }

    /**
     * 删除排队队列
     */
    @Log(title = "删除排队队列", businessType = BusinessType.DELETE)
    @PreAuthorize("@ss.hasPermi('vqms:queue:area:delete')")
    @DeleteMapping(value = "/{ids}")
    public AjaxResult delete(@PathVariable Long[] ids) {
        queueAreaService.delete(ids);
        return AjaxResult.success();
    }

}
